/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pojo;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jeferson
 */
@Entity
@Table(name = "TB_CLIENTE", catalog = "musical", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TbCliente.findAll", query = "SELECT t FROM TbCliente t"),
    @NamedQuery(name = "TbCliente.findByCliCodigo", query = "SELECT t FROM TbCliente t WHERE t.cliCodigo = :cliCodigo"),
    @NamedQuery(name = "TbCliente.findByCliNome", query = "SELECT t FROM TbCliente t WHERE t.cliNome = :cliNome"),
    @NamedQuery(name = "TbCliente.findByCliCpf", query = "SELECT t FROM TbCliente t WHERE t.cliCpf = :cliCpf"),
    @NamedQuery(name = "TbCliente.findByCliRg", query = "SELECT t FROM TbCliente t WHERE t.cliRg = :cliRg"),
    @NamedQuery(name = "TbCliente.findByCliEndereco", query = "SELECT t FROM TbCliente t WHERE t.cliEndereco = :cliEndereco"),
    @NamedQuery(name = "TbCliente.findByCliFone", query = "SELECT t FROM TbCliente t WHERE t.cliFone = :cliFone"),
    @NamedQuery(name = "TbCliente.findByCliBairro", query = "SELECT t FROM TbCliente t WHERE t.cliBairro = :cliBairro"),
    @NamedQuery(name = "TbCliente.findByCliLogin", query = "SELECT t FROM TbCliente t WHERE t.cliLogin = :cliLogin"),
    @NamedQuery(name = "TbCliente.findByCliSenha", query = "SELECT t FROM TbCliente t WHERE t.cliSenha = :cliSenha")})
public class TbCliente implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CLI_CODIGO")
    private Long cliCodigo;
    @Basic(optional = false)
    @Column(name = "CLI_NOME")
    private String cliNome;
    @Column(name = "CLI_CPF")
    private String cliCpf;
    @Column(name = "CLI_RG")
    private String cliRg;
    @Basic(optional = false)
    @Column(name = "CLI_ENDERECO")
    private String cliEndereco;
    @Column(name = "CLI_FONE")
    private String cliFone;
    @Basic(optional = false)
    @Column(name = "CLI_BAIRRO")
    private String cliBairro;
    @Basic(optional = false)
    @Column(name = "CLI_LOGIN")
    private String cliLogin;
    @Basic(optional = false)
    @Column(name = "CLI_SENHA")
    private String cliSenha;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vendCodcliente")
    private List<TbVenda> tbVendaList;
    @JoinColumn(name = "CLI_CODCIDADE", referencedColumnName = "CID_CODIGO")
    @ManyToOne(optional = false)
    private TbCidade cliCodcidade;

    public TbCliente() {
    }

    public TbCliente(Long cliCodigo) {
        this.cliCodigo = cliCodigo;
    }

    public TbCliente(Long cliCodigo, String cliNome, String cliEndereco, String cliBairro, String cliLogin, String cliSenha) {
        this.cliCodigo = cliCodigo;
        this.cliNome = cliNome;
        this.cliEndereco = cliEndereco;
        this.cliBairro = cliBairro;
        this.cliLogin = cliLogin;
        this.cliSenha = cliSenha;
    }

    public Long getCliCodigo() {
        return cliCodigo;
    }

    public void setCliCodigo(Long cliCodigo) {
        Long oldCliCodigo = this.cliCodigo;
        this.cliCodigo = cliCodigo;
        changeSupport.firePropertyChange("cliCodigo", oldCliCodigo, cliCodigo);
    }

    public String getCliNome() {
        return cliNome;
    }

    public void setCliNome(String cliNome) {
        String oldCliNome = this.cliNome;
        this.cliNome = cliNome;
        changeSupport.firePropertyChange("cliNome", oldCliNome, cliNome);
    }

    public String getCliCpf() {
        return cliCpf;
    }

    public void setCliCpf(String cliCpf) {
        String oldCliCpf = this.cliCpf;
        this.cliCpf = cliCpf;
        changeSupport.firePropertyChange("cliCpf", oldCliCpf, cliCpf);
    }

    public String getCliRg() {
        return cliRg;
    }

    public void setCliRg(String cliRg) {
        String oldCliRg = this.cliRg;
        this.cliRg = cliRg;
        changeSupport.firePropertyChange("cliRg", oldCliRg, cliRg);
    }

    public String getCliEndereco() {
        return cliEndereco;
    }

    public void setCliEndereco(String cliEndereco) {
        String oldCliEndereco = this.cliEndereco;
        this.cliEndereco = cliEndereco;
        changeSupport.firePropertyChange("cliEndereco", oldCliEndereco, cliEndereco);
    }

    public String getCliFone() {
        return cliFone;
    }

    public void setCliFone(String cliFone) {
        String oldCliFone = this.cliFone;
        this.cliFone = cliFone;
        changeSupport.firePropertyChange("cliFone", oldCliFone, cliFone);
    }

    public String getCliBairro() {
        return cliBairro;
    }

    public void setCliBairro(String cliBairro) {
        String oldCliBairro = this.cliBairro;
        this.cliBairro = cliBairro;
        changeSupport.firePropertyChange("cliBairro", oldCliBairro, cliBairro);
    }

    public String getCliLogin() {
        return cliLogin;
    }

    public void setCliLogin(String cliLogin) {
        String oldCliLogin = this.cliLogin;
        this.cliLogin = cliLogin;
        changeSupport.firePropertyChange("cliLogin", oldCliLogin, cliLogin);
    }

    public String getCliSenha() {
        return cliSenha;
    }

    public void setCliSenha(String cliSenha) {
        String oldCliSenha = this.cliSenha;
        this.cliSenha = cliSenha;
        changeSupport.firePropertyChange("cliSenha", oldCliSenha, cliSenha);
    }

    @XmlTransient
    public List<TbVenda> getTbVendaList() {
        return tbVendaList;
    }

    public void setTbVendaList(List<TbVenda> tbVendaList) {
        this.tbVendaList = tbVendaList;
    }

    public TbCidade getCliCodcidade() {
        return cliCodcidade;
    }

    public void setCliCodcidade(TbCidade cliCodcidade) {
        TbCidade oldCliCodcidade = this.cliCodcidade;
        this.cliCodcidade = cliCodcidade;
        changeSupport.firePropertyChange("cliCodcidade", oldCliCodcidade, cliCodcidade);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cliCodigo != null ? cliCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbCliente)) {
            return false;
        }
        TbCliente other = (TbCliente) object;
        if ((this.cliCodigo == null && other.cliCodigo != null) || (this.cliCodigo != null && !this.cliCodigo.equals(other.cliCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return cliLogin;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
